/**
 * [OElove] (C)2010-2099 oelove.com Inc. biz
 * Email: service@phpcoo.com ,phpcoo@qq.com
 * This is NOT a freeware, use is subject to license terms
 * $ Last update 2017/02/15 by OE $
*/
$(function(){
	
	//显示隐藏提示
	$(document).on("mouseover", "[f='show_netstar_tips']", function(){
		if ($("#netstar_tips").css("display") == "none") {
			$("#netstar_tips").show();
		}
	});
	$(document).on("mouseout", "[f='show_netstar_tips']", function(){
		if ($("#netstar_tips").css("display") == "block") {
			$("#netstar_tips").hide();
		}
	});

	//日期搜索
	$(document).on("click", "[f='but_submit_ser']", function(){
		$("#myform").submit();
	});
	//选择日期
	$(document).on("click", "[f='selet_difftype']", function(){
		$("[f='selet_difftype']").removeClass("current");
		$(this).addClass("current");
		$_val = $(this).attr("data-val");
		if (typeof($_val) == "undefined") {
			$_val = "";
		}
		$("#difftype").val($_val);
		$("#sdate").val("");
		$("#edate").val("");
		$("#myform").submit();

	});

	//提现记录 显示拒绝理由
	$(document).on("mouseover", "[f='show_reject_memo']", function(){
		if ($(this).parent().find("div").css("display") == "none") {
			$(this).parent().find("div").show();
		}
	});
	$(document).on("mouseout", "[f='show_reject_memo']", function(){
		if ($(this).parent().find("div").css("display") == "block") {
			$(this).parent().find("div").hide();
		}
	});

	
	//弹出提现页面 JSON
	$(document).on("click", "[f='but_open_withdraw']", function(){
		$ajax_url = _OE_FILE + "&c=withdraw&a=with";
		oeShadeBox("add_withdraw", "ajax", $ajax_url, 550, 400);
	});
	//弹出转入余额 JSON
	$(document).on("click", "[f='but_open_trans']", function(){
		$ajax_url = _OE_FILE + "&c=withdraw&a=trans";
		oeShadeBox("add_trans", "ajax", $ajax_url, 500, 300);
	});
	

	//提交申请网红会员
	$(document).on("click", "[f='but_app_netstar']", function(){
		$.ajax({
			type: "POST",
			url: _ROOT_PATH+"index.php?m=user&c=withdraw",
			cache: false,
			data: {a:"appstar", r:get_rndnum(8)},
			dataType: "json",
			success: function($data) {
				$json = eval($data);
				$response = $json.response;
				$result = $json.result;
				if ($response == "1") {
					ToastShow("申请成功");
					setTimeout(function(){
						window.location.reload();
					}, 500);
				}
				else {
					if ($result.length > 0) {
						ToastShow($result);
					}
					else {
						ToastShow("申请失败");
					}
				}
			},
			error: function() {
				ToastShow("系统繁忙，请稍后再试");
			}
		});
	});

	//统计提现手续费
	$(document).on("blur", "#with_money", function(){
		$_val = $(this).val();
		if ($_val.length > 0) {
			$.ajax({
				type: "POST",
				url: _ROOT_PATH+"index.php?m=user&c=withdraw",
				cache: false,
				data: {a:"countfee", money:$_val, r:get_rndnum(8)},
				dataType: "json",
				success: function($data) {
					$json = eval($data);
					$response = $json.response;
					$result = $json.result;
					if ($response == "1") {
						$("#with_fee_tips").html("￥"+$result);
					}
					else {
						if ($result.length > 0) {
							ToastShow($result);
						}
						else {
							ToastShow("获取失败");
						}
					}
				},
				error: function() {
					ToastShow("系统繁忙，请稍后再试");
				}
			});
		}
	});

	//确定提现
	$(document).on("click", "[f='but_save_with']", function(){
		$_money = $("#with_money").val();
		if ($_money.length == 0) {
			ToastShow("请输入提现金额");
			return false;
		}
		$payword = $("#payword").val();
		if ($payword.length == 0) {
			ToastShow("请输入安全密码");
			return false;
		}

		$.ajax({
			type: "POST",
			url: _ROOT_PATH+"index.php?m=user&c=withdraw",
			cache: false,
			data: {a:"savewith", money:$_money, payword:$payword, r:get_rndnum(8)},
			dataType: "json",
			success: function($data) {
				$json = eval($data);
				$response = $json.response;
				$result = $json.result;
				if ($response == "1") {
					ToastShow("操作成功，请等待网站处理");
					_closeShadeBox("add_withdraw", function(){
						setTimeout(function(){
							window.location.reload();
						}, 500);
					});
				}
				else {
					if ($result.length > 0) {
						ToastShow($result);
					}
					else {
						ToastShow("提现失败");
					}
				}
			},
			error: function() {
				ToastShow("系统繁忙，请稍后再试");
			}
		});
	});

	//确定转入
	$(document).on("click", "[f='but_save_trans']", function(){
		$_money = $("#trans_money").val();
		if ($_money.length == 0) {
			ToastShow("请输入转入金额");
			return false;
		}
		$payword = $("#payword").val();
		if ($payword.length == 0) {
			ToastShow("请输入安全密码");
			return false;
		}


		$.ajax({
			type: "POST",
			url: _ROOT_PATH+"index.php?m=user&c=withdraw",
			cache: false,
			data: {a:"savetrans", quantity:$_money, payword:$payword, r:get_rndnum(8)},
			dataType: "json",
			success: function($data) {
				$json = eval($data);
				$response = $json.response;
				$result = $json.result;
				if ($response == "1") {
					ToastShow("操作成功");
					_closeShadeBox("add_trans", function(){
						setTimeout(function(){
							window.location.reload();
						}, 500);
					});
				}
				else {
					if ($result.length > 0) {
						ToastShow($result);
					}
					else {
						ToastShow("转入失败");
					}
				}
			},
			error: function() {
				ToastShow("系统繁忙，请稍后再试");
			}
		});

	});



});